//package com.naiterui.ehp.bs.recommend.dao.impl;
//
//import java.util.List;
//
//import org.springframework.stereotype.Repository;
//
//import com.naiterui.common.repository.hibernate.CompatibleBaseDaoImpl;
//import com.naiterui.common.repository.page.Page;
//import com.naiterui.ehp.bs.recommend.bean.DrCommonPrescription;
//import com.naiterui.ehp.bs.recommend.bean.DrCommonPrescriptionDetail;
//import com.naiterui.ehp.bs.recommend.dao.IDrCommonPrescriptionDao;
//
//
//@Repository
//public class DrCommonPrescriptionDaoImpl extends CompatibleBaseDaoImpl<DrCommonPrescription, Long> implements IDrCommonPrescriptionDao {
//
//    @Override
//    public Page<DrCommonPrescription> getDrPageInfo(Long doctorId, int page, int num, int offset) {
//        String hql = "from DrCommonPrescription where doctorId=? order by changed_at desc";
//        return super.pagedQueryOffset(hql, page, num, offset, doctorId);
//    }
//
//    @Override
//    public void removeCommonPrescription(Long id) {
//        String sqlPrescription = "delete from dr_common_prescription where id=?";
//        super.executeSQL(sqlPrescription, id);
//        this.removeAllPresriptionDetail(id);
//    }
//
//    @Override
//    public List<DrCommonPrescriptionDetail> getCommonPrescriptionDetailList(Long id) {
//        String hql = "from DrCommonPrescriptionDetail where prescriptionId = ? order by id asc";
//        List<DrCommonPrescriptionDetail> commonPrescriptionDetailList = this.findForAny(hql, id);
//        return commonPrescriptionDetailList;
//    }
//
//    @Override
//    public Long saveCommonPrescription(DrCommonPrescription commonPrescription) {
//        super.save(commonPrescription);
//        return commonPrescription.getId();
//    }
//
//    @Override
//    public void update(DrCommonPrescription commonPrescription) {
//        super.update(commonPrescription);
//    }
//
//    @Override
//    public void removePresriptionDetail(Long id) {
//        String sql = "delete from dr_common_prescription_detail where id=?";
//        super.executeSQL(sql, id);
//    }
//
//    @Override
//    public DrCommonPrescription getCommonPrescription(Long id) {
//        return super.get(id);
//    }
//
//    @Override
//    public DrCommonPrescriptionDetail getPrescriptionDetailInfo(Long id) {
//        String hql = "FROM DrCommonPrescriptionDetail WHERE id =?";
//        List<DrCommonPrescriptionDetail> detail = super.findForAny(hql, id);
//        if (detail != null && !detail.isEmpty()) {
//            return detail.get(0);
//        } else {
//            return null;
//        }
//    }
//
//    @Override
//    public void removeAllPresriptionDetail(Long id) {
//        String sqlDetail = "delete from dr_common_prescription_detail where prescription_id=?";
//        super.executeSQL(sqlDetail, id);
//    }
//
//}
